package com.zzyl.serve.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzyl.serve.dto.DeviceDto;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Set;

import com.zzyl.serve.domain.Device;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 设备Mapper接口
 * 
 * @author liufan
 * @date 2025-08-22
 */
@Mapper
public interface DeviceMapper extends BaseMapper<Device>
{
    /**
     * 查询设备
     * 
     * @param id 设备主键
     * @return 设备
     */
    public Device selectDeviceById(Long id);

    /**
     * 查询设备列表
     * 
     * @param device 设备
     * @return 设备集合
     */
    public List<Device> selectDeviceList(Device device);

    /**
     * 新增设备
     * 
     * @param device 设备
     * @return 结果
     */
    public int insertDevice(Device device);

    /**
     * 修改设备
     * 
     * @param device 设备
     * @return 结果
     */
    public int updateDevice(Device device);

    /**
     * 删除设备
     * 
     * @param id 设备主键
     * @return 结果
     */
    public int deleteDeviceById(Long id);

    /**
     * 批量删除设备
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteDeviceByIds(Long[] ids);

    @Update("UPDATE zzyl2.device " +
            "SET node_id = #{deviceDto.nodeId}, " +
            "device_name = #{deviceDto.deviceName}, " +
            "binding_location = #{deviceDto.bindingLocation}, " +
            "location_type = #{deviceDto.locationType}, " +
            "physical_location_type = #{deviceDto.physicalLocationType}, " +
            "product_key = #{deviceDto.productKey}, " +
            "product_name = #{deviceDto.productName}, " +
            "device_description = #{deviceDto.deviceDescription}, " +
            "remark = #{deviceDto.remark} " +
            "WHERE id = #{deviceDto.id}")
    void updateByDevice(@Param("deviceDto") DeviceDto deviceDto);


    Set<Long> selectNurseIdsByElderIotId(String iotId);

    Set<Long> selectNurseIdsByBedIotId(String iotId);
}
